Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/58263
Change subject: Added handling for "phantom pages" (pages with an invalid
namespace)
......................................................................
Added handling for "phantom pages" (pages with an invalid namespace)
Change-Id: I57daebda2fea1e2f674483709e1a5a70d700b9b0
---
M includes/SF_Utils.php
1 file changed, 27 insertions(+), 20 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticForms
refs/changes/63/58263/1
diff --git a/includes/SF_Utils.php b/includes/SF_Utils.php
index e4bb6b7..c1a4e27 100644
--- a/includes/SF_Utils.php
+++ b/includes/SF_Utils.php
@@ -387,26 +387,33 @@
'SORT BY cl_sortkey' );
if ( $res ) {
while ( $res && $row = $db->fetchRow(
$res ) ) {
- if ( array_key_exists(
'page_title', $row ) ) {
- $page_namespace =
$row['page_namespace'];
- if ( $page_namespace ==
NS_CATEGORY ) {
- $new_category =
$row[ 'page_title' ];
- if ( !in_array(
$new_category, $categories ) ) {
-
$newcategories[] = $new_category;
- }
- } else {
- $cur_title =
Title::makeTitleSafe( $row['page_namespace'], $row['page_title'] );
- $cur_value =
self::titleString( $cur_title );
- if ( !
in_array( $cur_value, $pages ) ) {
-
$pages[] = $cur_value;
- }
- // return if
we've reached the maximum number of allowed values
- if ( count(
$pages ) > $sfgMaxAutocompleteValues ) {
- //
Remove duplicates, and put in alphabetical order.
- $pages
= array_unique( $pages );
- sort(
$pages );
- return
$pages;
- }
+ if ( !array_key_exists(
'page_title', $row ) ) {
+ continue;
+ }
+ $page_namespace =
$row['page_namespace'];
+ $page_name = $row[ 'page_title'
];
+ if ( $page_namespace ==
NS_CATEGORY ) {
+ if ( !in_array(
$page_name, $categories ) ) {
+
$newcategories[] = $page_name;
+ }
+ } else {
+ $cur_title =
Title::makeTitleSafe( $page_namespace, $page_name );
+ if ( is_null(
$cur_title ) ) {
+ // This can
happen if it's
+ // a "phantom"
page, in a
+ // namespace
that no longer exists.
+ continue;
+ }
+ $cur_value =
self::titleString( $cur_title );
+ if ( ! in_array(
$cur_value, $pages ) ) {
+ $pages[] =
$cur_value;
+ }
+ // return if we've
reached the maximum number of allowed values
+ if ( count( $pages ) >
$sfgMaxAutocompleteValues ) {
+ // Remove
duplicates, and put in alphabetical order.
+ $pages =
array_unique( $pages );
+ sort( $pages );
+ return $pages;
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/58263
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I57daebda2fea1e2f674483709e1a5a70d700b9b0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticForms
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
